<?php
require_once 'command/Command.php';
require_once 'database/GrosseryList.php';
require_once 'database/DatabaseConnection.php';

class AddToListCommand implements Command{

	private $id;
	private $productid;
	private $amount;
	private $grocerylist;

	public function __construct($id, $productid, $amount){
		$this->id = $id;
		$this->productid = $productid;
		$this->amount = $amount;
		$this->grocerylist = new GrosseryList();
	}

	public function execute(){
		DatabaseConnection::connect();
		$bool = $this->grocerylist->addToList($this->id, $this->productid, $this->amount);
		DatabaseConnection::disconnect();
		$string = "<succes>".$bool."</succes>";
		return $string;
	}
}